// 统计

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_baby_health_tracker/widgets/card.dart';

class StatisticScreen extends StatefulWidget {
  const StatisticScreen({super.key});

  @override
  State<StatisticScreen> createState() => _StatisticScreenState();
}

class _StatisticScreenState extends State<StatisticScreen> {

  final  List<String> filters = [
    '一体化统计',
    '喂奶',
    '睡眠',
    '尿布',
    '休闲',
    '成长',
  ];

  final ValueNotifier<int> current = ValueNotifier(0);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('统计'),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [
            Divider(
              height: 1,
            ),
            SingleChildScrollView(
              scrollDirection: Axis.horizontal,
              child: Padding(
                padding: const EdgeInsets.symmetric(horizontal: 8.0,vertical: 16),
                child: ValueListenableBuilder(
                  valueListenable: current,
                  builder: (context,c,child){
                    return Row(
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: List<Widget>.generate(filters.length, (index){
                          return GestureDetector(
                            onTap: (){
                              current.value = index;
                            },
                            child: Container(
                              padding: EdgeInsets.all(8),
                              margin: EdgeInsets.only(right: 8),
                              decoration: BoxDecoration(
                                  color:  index== c? CupertinoColors.systemGreen:Colors.white60,
                                  border: Border.all(
                                    color: Colors.grey,
                                    width: 1
                                  ),
                                borderRadius: BorderRadius.circular(8)
                              ),
                              child: Center(
                                child: Text(filters[index],style: TextStyle(
                                  color: index == c ? Colors.white: Colors.grey.shade600,
                                ),),
                              ),
                            ),
                          );
                        })
                    );
                  },
                ),
              ),
            ),
            Divider(
              height: 1,
            ),
            ValueListenableBuilder(valueListenable: current, builder: (context,c,child){
              if(c==0){
                return OverAllStatistic();
              }else if(c==1){
                return FeedStatistic();
              }else if(c==2){
                return SleepStatistic();
              }else if(c==3){
                return DiaperStatistic();
              }else if(c==4){
                return LeisureStatistic();
              }else if(c==5){
                return GrowthStatistic();
              }else{
                return OverAllStatistic();
              }
            })
          ],
        ),
      ),
    );
  }
}

// 一体化统计
class OverAllStatistic extends StatelessWidget {
  const OverAllStatistic({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        LiCard(

          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.only(bottom: 16.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('统计'),
                    DropdownButton(
                        elevation: 2,
                        isDense: true,
                        value: '7',
                        items: [
                      DropdownMenuItem<String>(value: '7',child: Text('7天'),),
                      DropdownMenuItem<String>(value: '14',child: Text('14天'),),
                      DropdownMenuItem<String>(value: '30',child: Text('30天'),),
                      DropdownMenuItem<String>(value: '0',child: Text('自定义'),)
                    ], onChanged: (s){
                          debugPrint(s);
                    })
                  ],
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(bottom: 8.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('平均每日喂奶次数'),
                    Text('12',style: TextStyle(
                      fontWeight: FontWeight.bold
                    ),)
                  ],
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(bottom: 8.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('平均每日睡眠时长'),
                    Text('12小时',style: TextStyle(
                        fontWeight: FontWeight.bold
                    ),)
                  ],
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(bottom: 8.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('平均每日换尿布次数'),
                    Text('2',style: TextStyle(
                        fontWeight: FontWeight.bold
                    ),)
                  ],
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(bottom: 8.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('平均每日休闲时间'),
                    Text('23分钟',style: TextStyle(
                        fontWeight: FontWeight.bold
                    ),)
                  ],
                ),
              )
            ],
          ),
        ),
        LiCard(

          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.only(bottom: 16.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('宝宝时间表'),
                    Icon(Icons.zoom_out_map_rounded,color: Colors.black,)
                  ],
                ),
              ),
              Padding(padding: EdgeInsets.all(8),child: Text('显示宝宝在所选时间内地所有活动，待开发'),),
            ],
          ),
        )
      ],
    );
  }
}
// 喂养统计
class FeedStatistic extends StatelessWidget {
  const FeedStatistic({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        LiCard(

          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.only(bottom: 16.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('统计'),
                    DropdownButton(
                        elevation: 2,
                        isDense: true,
                        value: '7',
                        items: [
                          DropdownMenuItem<String>(value: '7',child: Text('7天'),),
                          DropdownMenuItem<String>(value: '14',child: Text('14天'),),
                          DropdownMenuItem<String>(value: '30',child: Text('30天'),),
                          DropdownMenuItem<String>(value: '0',child: Text('自定义'),)
                        ], onChanged: (s){
                      debugPrint(s);
                    })
                  ],
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(bottom: 8.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('平均每日喂奶次数'),
                    Text('12',style: TextStyle(
                        fontWeight: FontWeight.bold
                    ),)
                  ],
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(bottom: 8.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('平均每次喂奶时长'),
                    Text('30分钟',style: TextStyle(
                        fontWeight: FontWeight.bold
                    ),)
                  ],
                ),
              ),
            ],
          ),
        ),
        LiCard(

          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.only(bottom: 16.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('每日喂奶时长'),
                  ],
                ),

              ),
              Padding(padding: EdgeInsets.all(8),child: Text('显示宝宝在所选时间内的每日喂奶时长，待开发'),),
            ],
          ),
        ),
        LiCard(

          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.only(bottom: 16.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('喂奶时间表'),
                    Icon(Icons.zoom_out_map_rounded,color: Colors.black,)
                  ],
                ),
              ),
              Padding(padding: EdgeInsets.all(8),child: Text('显示宝宝在所选时间内喂奶时间，待开发'),),
            ],
          ),
        )
      ],
    );
  }
}

//睡眠统计
class SleepStatistic extends StatelessWidget {
  const SleepStatistic({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        LiCard(

          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.only(bottom: 16.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('统计'),
                    DropdownButton(
                        elevation: 2,
                        isDense: true,
                        value: '7',
                        items: [
                          DropdownMenuItem<String>(value: '7',child: Text('7天'),),
                          DropdownMenuItem<String>(value: '14',child: Text('14天'),),
                          DropdownMenuItem<String>(value: '30',child: Text('30天'),),
                          DropdownMenuItem<String>(value: '0',child: Text('自定义'),)
                        ], onChanged: (s){
                      debugPrint(s);
                    })
                  ],
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(bottom: 8.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('平均每日睡眠时长'),
                    Text('12',style: TextStyle(
                        fontWeight: FontWeight.bold
                    ),)
                  ],
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(bottom: 8.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('平均每日次数'),
                    Text('30分钟',style: TextStyle(
                        fontWeight: FontWeight.bold
                    ),)
                  ],
                ),
              ),
            ],
          ),
        ),
        LiCard(

          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.only(bottom: 16.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('每日睡眠时长'),
                  ],
                ),

              ),
              Padding(padding: EdgeInsets.all(8),child: Text('显示宝宝在所选时间内的每日喂奶时长，待开发'),),
            ],
          ),
        ),
        LiCard(

          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.only(bottom: 16.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('睡眠时间表'),
                    Icon(Icons.zoom_out_map_rounded,color: Colors.black,)
                  ],
                ),
              ),
              Padding(padding: EdgeInsets.all(8),child: Text('显示宝宝在所选时间内喂奶时间，待开发'),),
            ],
          ),
        ),
        LiCard(

          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.only(bottom: 16.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('每日白天睡眠时长'),
                    Icon(Icons.zoom_out_map_rounded,color: Colors.black,)
                  ],
                ),
              ),
              Padding(padding: EdgeInsets.all(8),child: Text('显示宝宝在所选时间内喂奶时间，待开发'),),
            ],
          ),
        ),
        LiCard(

          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.only(bottom: 16.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('每日夜间睡眠时长'),
                    Icon(Icons.zoom_out_map_rounded,color: Colors.black,)
                  ],
                ),
              ),
              Padding(padding: EdgeInsets.all(8),child: Text('显示宝宝在所选时间内喂奶时间，待开发'),),
            ],
          ),
        ),
      ],
    );
  }
}

//尿布统计
class DiaperStatistic extends StatelessWidget {
  const DiaperStatistic({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        LiCard(

          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.only(bottom: 16.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('统计'),
                    DropdownButton(
                        elevation: 2,
                        isDense: true,
                        value: '7',
                        items: [
                          DropdownMenuItem<String>(value: '7',child: Text('7天'),),
                          DropdownMenuItem<String>(value: '14',child: Text('14天'),),
                          DropdownMenuItem<String>(value: '30',child: Text('30天'),),
                          DropdownMenuItem<String>(value: '0',child: Text('自定义'),)
                        ], onChanged: (s){
                      debugPrint(s);
                    })
                  ],
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(bottom: 8.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('每日换尿布次数'),
                    Text('1',style: TextStyle(
                        fontWeight: FontWeight.bold
                    ),)
                  ],
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(bottom: 8.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('每日尿湿次数'),
                    Text('1',style: TextStyle(
                        fontWeight: FontWeight.bold
                    ),)
                  ],
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(bottom: 8.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('每日便便次数'),
                    Text('1',style: TextStyle(
                        fontWeight: FontWeight.bold
                    ),)
                  ],
                ),
              ),
            ],
          ),
        ),
        LiCard(

          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.only(bottom: 16.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('每日换尿布次数'),
                  ],
                ),

              ),
              Padding(padding: EdgeInsets.all(8),child: Text('显示宝宝在所选时间内的每日喂奶时长，待开发'),),
            ],
          ),
        ),
      ],
    );
  }
}

// 休闲统计
class LeisureStatistic extends StatelessWidget {
  const LeisureStatistic({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        LiCard(

          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.only(bottom: 16.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('统计'),
                    DropdownButton(
                        elevation: 2,
                        isDense: true,
                        value: '7',
                        items: [
                          DropdownMenuItem<String>(value: '7',child: Text('7天'),),
                          DropdownMenuItem<String>(value: '14',child: Text('14天'),),
                          DropdownMenuItem<String>(value: '30',child: Text('30天'),),
                          DropdownMenuItem<String>(value: '0',child: Text('自定义'),)
                        ], onChanged: (s){
                      debugPrint(s);
                    })
                  ],
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(bottom: 8.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('平均每日俯卧时间'),
                    Text('12',style: TextStyle(
                        fontWeight: FontWeight.bold
                    ),)
                  ],
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(bottom: 8.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('平均每日玩耍时间'),
                    Text('30分钟',style: TextStyle(
                        fontWeight: FontWeight.bold
                    ),)
                  ],
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(bottom: 8.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('平均每日户外活动时长'),
                    Text('30分钟',style: TextStyle(
                        fontWeight: FontWeight.bold
                    ),)
                  ],
                ),
              ),
            ],
          ),
        ),
        LiCard(

          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.only(bottom: 16.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('休闲时间表'),
                    Icon(Icons.zoom_out_map_rounded,color: Colors.black,)
                  ],
                ),

              ),
              Padding(padding: EdgeInsets.all(8),child: Text('显示宝宝在所选时间内的每日喂奶时长，待开发'),),
            ],
          ),
        ),
        LiCard(

          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.only(bottom: 16.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('洗澡时长'),

                  ],
                ),
              ),
              Padding(padding: EdgeInsets.all(8),child: Text('显示宝宝在所选时间内喂奶时间，待开发'),),
            ],
          ),
        ),
      ],
    );
  }
}

//成长统计
class GrowthStatistic extends StatelessWidget {
  const GrowthStatistic({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [

        LiCard(

          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.only(bottom: 16.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('体重图表'),
                  ],
                ),

              ),
              Padding(padding: EdgeInsets.all(8),child: Text('显示宝宝在所选时间内的每日喂奶时长，待开发'),),
            ],
          ),
        ),
        LiCard(

          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.only(bottom: 16.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('身高图表'),
                    Icon(Icons.zoom_out_map_rounded,color: Colors.black,)
                  ],
                ),
              ),
              Padding(padding: EdgeInsets.all(8),child: Text('显示宝宝在所选时间内喂奶时间，待开发'),),
            ],
          ),
        ),
        LiCard(

          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.only(bottom: 16.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('头围图表'),
                    Icon(Icons.zoom_out_map_rounded,color: Colors.black,)
                  ],
                ),
              ),
              Padding(padding: EdgeInsets.all(8),child: Text('显示宝宝在所选时间内喂奶时间，待开发'),),
            ],
          ),
        ),
      ],
    );
  }
}

// // 健康统计
// class HealthStatistic extends StatelessWidget {
//   const HealthStatistic({super.key});
//
//   @override
//   Widget build(BuildContext context) {
//     return Column(
//       children: [
//         Container(
//           margin: EdgeInsets.all(8),
//           padding: EdgeInsets.all(8),
//           decoration: BoxDecoration(
//               borderRadius: BorderRadius.circular(8),color: Color(0xfff7f7e3)
//           ),
//           child: Column(
//             children: [
//               Padding(
//                 padding: const EdgeInsets.only(bottom: 16.0),
//                 child: Row(
//                   mainAxisAlignment: MainAxisAlignment.spaceBetween,
//                   children: [
//                     Text('统计'),
//                     DropdownButton(
//                         elevation: 2,
//                         isDense: true,
//                         value: '7',
//                         items: [
//                           DropdownMenuItem<String>(value: '7',child: Text('7天'),),
//                           DropdownMenuItem<String>(value: '14',child: Text('14天'),),
//                           DropdownMenuItem<String>(value: '30',child: Text('30天'),),
//                           DropdownMenuItem<String>(value: '0',child: Text('自定义'),)
//                         ], onChanged: (s){
//                       debugPrint(s);
//                     })
//                   ],
//                 ),
//               ),
//               Padding(
//                 padding: const EdgeInsets.only(bottom: 8.0),
//                 child: Row(
//                   mainAxisAlignment: MainAxisAlignment.spaceBetween,
//                   children: [
//                     Text('平均每日睡眠时长'),
//                     Text('12',style: TextStyle(
//                         fontWeight: FontWeight.bold
//                     ),)
//                   ],
//                 ),
//               ),
//               Padding(
//                 padding: const EdgeInsets.only(bottom: 8.0),
//                 child: Row(
//                   mainAxisAlignment: MainAxisAlignment.spaceBetween,
//                   children: [
//                     Text('平均每日次数'),
//                     Text('30分钟',style: TextStyle(
//                         fontWeight: FontWeight.bold
//                     ),)
//                   ],
//                 ),
//               ),
//             ],
//           ),
//         ),
//         Container(
//           margin: EdgeInsets.all(8),
//           padding: EdgeInsets.all(8),
//           decoration: BoxDecoration(
//               borderRadius: BorderRadius.circular(8),color: Color(0xfff7f7e3)
//           ),
//           child: Column(
//             children: [
//               Padding(
//                 padding: const EdgeInsets.only(bottom: 16.0),
//                 child: Row(
//                   mainAxisAlignment: MainAxisAlignment.spaceBetween,
//                   children: [
//                     Text('每日睡眠时长'),
//                   ],
//                 ),
//
//               ),
//               Padding(padding: EdgeInsets.all(8),child: Text('显示宝宝在所选时间内的每日喂奶时长，待开发'),),
//             ],
//           ),
//         ),
//         Container(
//           margin: EdgeInsets.all(8),
//           padding: EdgeInsets.all(8),
//           decoration: BoxDecoration(
//               borderRadius: BorderRadius.circular(8),color: Color(0xfff7f7e3)
//           ),
//           child: Column(
//             children: [
//               Padding(
//                 padding: const EdgeInsets.only(bottom: 16.0),
//                 child: Row(
//                   mainAxisAlignment: MainAxisAlignment.spaceBetween,
//                   children: [
//                     Text('睡眠时间表'),
//                     Icon(Icons.zoom_out_map_rounded,color: Colors.black,)
//                   ],
//                 ),
//               ),
//               Padding(padding: EdgeInsets.all(8),child: Text('显示宝宝在所选时间内喂奶时间，待开发'),),
//             ],
//           ),
//         ),
//         Container(
//           margin: EdgeInsets.all(8),
//           padding: EdgeInsets.all(8),
//           decoration: BoxDecoration(
//               borderRadius: BorderRadius.circular(8),color: Color(0xfff7f7e3)
//           ),
//           child: Column(
//             children: [
//               Padding(
//                 padding: const EdgeInsets.only(bottom: 16.0),
//                 child: Row(
//                   mainAxisAlignment: MainAxisAlignment.spaceBetween,
//                   children: [
//                     Text('每日白天睡眠时长'),
//                     Icon(Icons.zoom_out_map_rounded,color: Colors.black,)
//                   ],
//                 ),
//               ),
//               Padding(padding: EdgeInsets.all(8),child: Text('显示宝宝在所选时间内喂奶时间，待开发'),),
//             ],
//           ),
//         ),
//         Container(
//           margin: EdgeInsets.all(8),
//           padding: EdgeInsets.all(8),
//           decoration: BoxDecoration(
//               borderRadius: BorderRadius.circular(8),color: Color(0xfff7f7e3)
//           ),
//           child: Column(
//             children: [
//               Padding(
//                 padding: const EdgeInsets.only(bottom: 16.0),
//                 child: Row(
//                   mainAxisAlignment: MainAxisAlignment.spaceBetween,
//                   children: [
//                     Text('每日夜间睡眠时长'),
//                     Icon(Icons.zoom_out_map_rounded,color: Colors.black,)
//                   ],
//                 ),
//               ),
//               Padding(padding: EdgeInsets.all(8),child: Text('显示宝宝在所选时间内喂奶时间，待开发'),),
//             ],
//           ),
//         ),
//       ],
//     );
//   }
// }
